import 'package:flutter/material.dart';
import 'package:flutter_app/scoped_model/auth.dart';
import 'package:flutter_app/utils/scoped_model_helper.dart';
import 'package:flutter_app/widgets/button_column.dart';

class ListClassify extends StatefulWidget {
  const ListClassify({Key? key}) : super(key: key);

  @override
  State<ListClassify> createState() => _ListClassifyState();
}

class _ListClassifyState extends State<ListClassify> {
  @override
  Widget build(BuildContext context) {
    bool isLogin = ScopedHelperModel.getModel<AuthModel>(context).isLogin;

    List _buildButtonColumnList = [
      {
        "pushUrl": '/login',
        "icon": Icons.timer_rounded,
        "name": '看房记录',
        "color": Colors.blue
      },
      {
        "pushUrl": '/login',
        "icon": Icons.event_note_rounded,
        "name": '我的订单',
        "color": Colors.purple
      },
      {
        "pushUrl": isLogin ? '/myCollection' : '/login',
        "icon": Icons.collections_bookmark_rounded,
        "name": '我的收藏',
        "color": Colors.red[300]
      },
      {
        "pushUrl": '/login',
        "icon": Icons.call,
        "name": '身份认证',
        "color": Colors.yellow
      },
      {
        "pushUrl": '/login',
        "icon": Icons.message_rounded,
        "name": '联系我们',
        "color": Colors.redAccent
      },
      {
        "pushUrl": '/login',
        "icon": Icons.my_library_books_rounded,
        "name": '电子合同',
        "color": Colors.blue
      },
      {
        "pushUrl": isLogin ? '/houseManagement' : '/login',
        "icon": Icons.location_city_rounded,
        "name": '房屋管理',
        "color": Colors.purple
      },
      {
        "pushUrl": '/login',
        "icon": Icons.money,
        "name": '钱包',
        "color": Colors.yellow
      },
    ];

    return Padding(
      padding: const EdgeInsets.all(10),
      child: Wrap(
        spacing: 20, // 主轴(水平)方向间距
        runSpacing: 10, // 纵轴（垂直）方向间距
        children: _buildButtonColumnList
            .map((e) => SizedBox(
                  child: BuildButtonColumn(
                    icon: e["icon"],
                    label: e["name"],
                    color: e["color"],
                    pushUrl: e["pushUrl"],
                  ),
                  width: 110,
                ))
            .toList(),
      ),
    );
  }
}
